package ejemplos;

import julupanter.blogspot.com.VozTTS;



public class HelloVoice extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6223309901604380125L;
	
	private VozTTS voz;

	/** Creates new form HelloSapi5 */
	public HelloVoice() {
		initComponents();
		voz = new VozTTS();
	}


	private void initComponents() {
		jButton1 = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();
		jButton3 = new javax.swing.JButton();

		addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent evt) {
				exitForm(evt);
			}
		});

		jButton1.setText("Mira quien soy");
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		getContentPane().add(jButton1, java.awt.BorderLayout.NORTH);


		jButton2.setText("Deja que te insulte");
		jButton2.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton2ActionPerformed(evt);
			}
		});

		getContentPane().add(jButton2, java.awt.BorderLayout.SOUTH);

		jButton3.setText("Cambia la voz aleatoriamente");
		jButton3.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				cambiarVoz(-1);
			}
		});

		getContentPane().add(jButton3, java.awt.BorderLayout.EAST);

		pack();
	}

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		if (this.getLocale().getLanguage().equals("es"))
			voz.speak("Hola, soy la voz de "+voz.getVoiceName()+ " \\_Breath_01" );
		System.out.println("Hola, soy la voz de "+voz.getVoiceName()+ "     \\_Breath_01" );
	}

	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
		voz.insulta();
	}

	private void cambiarVoz(int posicion) {
		voz.cambiarVoz(posicion);
	}

	/** Exit the Application */
	private void exitForm(java.awt.event.WindowEvent evt) {
		voz.disposeVoz();
		System.exit(0);
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		HelloVoice hv = new HelloVoice();
		hv.setVisible(true);
		hv.setLocationRelativeTo(null);
	}


	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton jButton1,jButton2,jButton3;
	// End of variables declaration//GEN-END:variables

}
